Skip to content

fix: repair failing tests and type errors across api and shared packages - #98

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2487-1784824599
Open

fix: repair failing tests and type errors across api and shared packages#98
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2487-1784824599

Conversation

@stooit

@stooit stooit commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes bun test && bunx tsc --noEmit fully pass — 22/22 tests green, zero type errors. Fixes span both the api and shared packages. No test files were modified and no dependencies were added.

Fixes

  • Pagination utility (packages/shared/src/utils/pagination.ts): implemented the paginate() stub per the test contract — page slicing, total/totalPages, page/pageSize, out-of-range → empty data, empty-array handling, and a divide-by-zero guard for size = 0.
  • Auth middleware (packages/api/src/middleware/auth.ts): fixed a case-sensitivity bug — the public-route allow-list now compares against uppercase HTTP methods (Hono exposes c.req.method as uppercase), so POST /users is correctly public.
  • Users route (packages/api/src/routes/users.ts): added the missing badRequest import that caused a runtime/type failure, and reconciled the request-body field to username.
  • Shared types (packages/shared/src/types.ts): renamed User.userNameusername to match what the route, db layer, and tests all expect (tests treated as source of truth).
  • tsconfig (tsconfig.json): added typeRoots/types so TypeScript resolves the already-installed @types/node and bun-types. Pure compiler config — no new dependency.

Assumptions

  • The tests are the source of truth for the correct field name (username) and API contract; non-test code was changed to match.
  • @types/node and bun-types were already present in node_modules; the tsconfig change only points the compiler at them.

Verification

  • bun test → 22 pass, 0 fail
  • bunx tsc --noEmit → exit 0, no errors
  • Independent review pass: clean bill of health on all five changed files.

- implement paginate() stub with correct slicing, totals, and edge-case handling
- fix auth middleware public-method allow-list (uppercase HTTP method comparison)
- add missing badRequest import in users route
- reconcile User.username field name across shared types and api route
- wire @types/node/bun-types via tsconfig typeRoots (no new dependency)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant